<template>
	<div class="orderContext">
		 <van-list
		   v-model="loading"
		   :finished="finished"
		   :finished-text="finishedText"
		   @load="onLoad"
		 >
		   <van-cell v-for="item in list"  :key="item.orderId">
		       <template #default>
		         <div>
		           <p>订单时间 {{item.createTime}}---- {{item.orderStatusString}}</p>
		           <img
		             v-for='v in item.newBeeMallOrderItemVOS'
		             :src="v.goodsCoverImg"
		             alt=""
		           >
		           <p>总价格 {{item.totalPrice}}</p>
				   <hr>
		         </div>
		       </template>
		   </van-cell>
		 </van-list> 
	</div>
</template>


<script>
import {getOrderList} from "../api/index.js";
export default {
  name: 'OrderContext',
  props:["status"],
  data(){
	  return{
		list: [],
		loading: false,
		finished: false,
		pageNumber: 1,
		finishedText:"没有更多了",
		num:1
	  }
  },
  methods: {
    onLoad() {
      // 异步更新数据
       getOrderList(this.pageNumber, this.status).then(data=>{
		   console.log(data);
		   if(data.data.list.length==0){
			   if(this.num==1){
				   this.finishedText="暂无数据";
			   }else{
				   this.finishedText="没有更多了";
			   }
			   this.finished = true;
		   }
		   if(data.resultCode==200){
			   this.list = this.list.concat(data.data.list);
			   this.loading = false;
			   this.num++;
		   }
		   this.pageNumber++;
	   })
    },
  },
}
</script>


<style lang="less" scoped>
.orderContext{
	height:100%;
	width:100%;
	img{
		width:100%;
	}
}
</style>
